<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Form</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>

    <style type="text/css">
        html,body
        {
            padding:0;
            margin:0;
            border:0;
            width:100%;
            height:100%;
            overflow:hidden;
        }
    </style>

</head>
<body>
<div class="mini-toolbar" style="text-align:center;line-height:30px;" borderStyle="border:0;">
    <label >名称：</label>
    <input id="key" class="mini-textbox" style="width:150px;" onenter="onKeyEnter"/>
    <a class="mini-button" style="width:60px;" onclick="search()">查询</a>
</div>
<div class="mini-fit">

    <div id="grid1" class="mini-datagrid" style="width:100%;height:100%;"
         idField="id"
         allowResize="true" showPager='false'
         allowCellEdit="true" allowCellSelect="true" multiSelect="true"
    >
        <div property="columns">
            <!--<div type="checkcolumn" ></div>-->
            <div field="name" width="120" headerAlign="center">清单名</div>
            <div field="type" width="50" headerAlign="center">类型</div>
            <div field="emp_no" width="50" headerAlign="center">产品经理</div>
            <div field="ctime" width="120" headerAlign="center">通知时间</div>
            <div field="remark" width="150" headerAlign="center">备注
                <input  class="mini-textbox" property="editor" style="width:100%;"/>
            </div>
        </div>
    </div>

</div>
<div class="mini-toolbar" style="text-align:center;padding-top:8px;padding-bottom:8px;" borderStyle="border:0;">
    <a class="mini-button" style="width:60px;" onclick="onOk()">确定</a>
    <span style="display:inline-block;width:25px;"></span>
    <a class="mini-button" style="width:60px;" onclick="onCancel()">取消</a>
</div>

</body>
</html>
<script type="text/javascript">
    mini.parse();

    var grid = mini.get("grid1");

    grid.on("drawcell", function (e) {
        var record = e.record,
            column = e.column,
            field = e.field,
            value = e.value;

        //格式化日期
        if (field == "ctime") {
            if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd H:m:s");
        }

        if (field == "type") {
            if(value == 0){
                e.cellHtml = "普通";
            }
            if(value == 1){
                e.cellHtml = "活动";
            }
            if(value == 2){
                e.cellHtml = "集采";
            }
        }

    });

    //grid.setPageSize(50);

    //动态设置URL
    grid.setUrl("/Goods/listshelves/customerCode/<?php echo $customerCode; ?>");
    //也可以动态设置列 grid.setColumns([]);

    grid.load();

    function GetSelecteds() {
        var rows = grid.getSelecteds();
        return rows;
    }
    function GetData() {
        var rows = grid.getSelecteds();
        var ids = [], texts = [];
        for (var i = 0, l = rows.length; i < l; i++) {
            var row = rows[i];
            ids.push(row.id);
            texts.push(row.name);
        }
        var data = {};
        data.id = ids.join(",");
        data.text = texts.join(",");
        return data;
    }

    function search() {
        var key = mini.get("key").getValue();
        grid.load({ key: key });
    }
    function onKeyEnter(e) {
        search();
    }
    //////////////////////////////////
    function CloseWindow(action) {
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }

    function onOk() {
        CloseWindow("ok");
    }
    function onCancel() {
        CloseWindow("cancel");
    }


</script>
</body>
</html>

